import {
	HTTP_REQUEST_URL
} from '@/config.js';
var baseUrl = HTTP_REQUEST_URL

export const http = function(url, data, Fn, type, Fn2) {
	return uni.request({
		url: baseUrl + url, //仅为示例，并非真实接口地址。
		data: data,
		method: type ? type : 'POST',
		header: {
			'Authorization': 'Bearer ' + uni.getStorageSync('token'),
		},
		fail: (err) => {
			uni.hideLoading()
		},
		success: (res) => {
			if (res.data.error) {
				if (res.data.error.message == '当前微信号未绑定') {
					if (Fn2) {
						Fn2(res)
					};
					return
				}
				if(url == '/minprogram/api/member/bind'){
					uni.showModal({
						content: res.data.error.message,
						showCancel: false
					})
				}else{
					uni.showToast({
						icon: 'none',
						title: res.data.error.message
					})
				}
				if (Fn2) {
					Fn2(res)
				}
			} else {
				Fn(res)
			}
		}
	})
}